package com.zxy;

import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;

import java.io.IOException;

/**
 * 1 实例化                   构造器        第一次请求
 * 2 初始化                   init         构造完毕
 * 3 接受请求，处理请求，服务    service      每次请求
 * 4 销毁                     destroy()    关闭服务
 *
 */
@WebServlet("/servletLifeCycle")
public class ServletLifeCycle extends HttpServlet {

    public ServletLifeCycle(){
        System.out.println("构造器");
    }

    @Override
    public void init() throws ServletException {
        System.out.println("初始化");
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        System.out.println("服务");
    }

    @Override
    public void destroy() {
        System.out.println("destroy");
    }
}
